import ReactDOM from 'react-dom'
import React, { Component } from 'react'

// 类组件定义状态
class App extends Component {

  state = {
    count: 0
  }

  // mouseenter的处理函数，默认参数是事件对象
  handleMouseEnter(e) {
    console.log('onMouseEnter')
    console.log(e)
  }

  // click的处理函数
  handleClick(e) {
    // 阻止默认行为
    e.preventDefault()
    // 阻止事件冒泡
    e.stopPropagation()
    console.log('onClick')
    console.log(e)
  }

  render() {
    return (
      <div>
        {/* 1. 绑定事件规则， on+事件名称={处理函数}，事件名称遵循大驼峰  */}
        <div onMouseEnter={this.handleMouseEnter} >计数器：{this.state.count}</div>
        <a href='http://www.itcast.cn' onClick={this.handleClick}>传智播客</a>
      </div>
    )
  }
}


ReactDOM.render(<App />, document.getElementById('root'))